/***************************************************************************************************
** WHAT: 	Replication file for the paper
			"Covid-19 vs. Ebola: impact on households and small businesses in North-Kivu, DRC",
			by Sébastien Desbureaux, Audacieux Kaota, Elie Lunanga, Nik Stoop, Marijke Verpoorten.
			Revise & Resubmit at World Development
				
			Below you find the code to reproduce the Tables and Figures,
			
** WHEN: 	October '20

** WHO:	 	Nik Stoop, nik.stoop@uantwerp.be
***************************************************************************************************/

clear all
set more off
set scheme s1mono
	
global data "ADD LOCATION OF DATABASE HERE"
	
*** Open database
	use "$data/covid_ebola.dta",clear
	
*** Table 1: Breakdown of sample by respondent type and location

	tab location hh 
	
*** Figure 1: map (not created in stata)
	
*** Figure 2: Self-reported impact of Covid-19 vs EVD in the full sample

	gen x=0
	gen y=0
	gen z=0
	graph hbar (mean) x revenu_corona revenu_ebola y food_corona food_ebola z crime_corona crime_ebola, legend(off) blabel(bar,format(%9.2f)) ylabel(0(0.2)1) ytitle("proportion of respondents")  ///
	ascategory yvar(relabel(1"{bf:Decreased revenue}" 2"{it:Covid-19}" 3"{it:EVD}" 4"{bf:Lower food security}" 5"{it:Covid-19}" 6"{it:EVD}" 7"{bf:Higher incidence of crime}" 8"{it:Covid-19}" 9"{it:EVD}"))
	gr_edit plotregion1.bars[1].EditCustomStyle , j(-1) style(shadestyle(color(gs13)))
	gr_edit plotregion1.bars[4].EditCustomStyle , j(-1) style(shadestyle(color(gs13)))
	gr_edit plotregion1.bars[7].EditCustomStyle , j(-1) style(shadestyle(color(gs13)))
	gr_edit plotregion1.barlabels[9].Delete
	gr_edit plotregion1.barlabels[6].Delete
	gr_edit plotregion1.barlabels[3].Delete
	drop x y z
	
	
	
*** Figure 3: Self-reported impact of Covid-19 vs EVD by location

	* combine graphs for each location
	graph hbar revenu_corona revenu_ebola, legend(off) over (location) yvar(relabel(1"Covid-19" 2"EVD"))  bar(2, fcolor(gs13)) blabel(bar,format(%9.2f)) yscale(range(0 1)) title("Decreased revenue") 
	graph save g1,replace
	graph hbar food_corona food_ebola, legend(off) over (location) yvar(relabel(1"Covid-19" 2"EVD"))  bar(2, fcolor(gs13)) blabel(bar,format(%9.2f)) yscale(range(0 1)) title("Lower food security") 
	graph save g2,replace			
	graph hbar crime_corona crime_ebola, legend(off) over (location) yvar(relabel(1"Covid-19" 2"EVD"))  bar(2, fcolor(gs13)) blabel(bar,format(%9.2f)) yscale(range(0 1)) title("Higher incidence of crime") 
	graph save g3,replace
	graph combine g1.gph g2.gph g3.gph, ycommon xcommon	
	
	* get legend
	graph hbar revenu_corona revenu_ebola, over (location) yvar(relabel(1"Covid-19" 2"EVD"))  bar(2, fcolor(gs13)) blabel(bar,format(%9.2f)) yscale(range(0 1)) title("Decreased revenue") 

	* t-test difference in means comparing Goma vs rural areas	
	gen goma=1 if location==1
	replace goma=0 if location==2 | location==3
	
	local var "revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola"
	foreach v of local var{
	ttest `v' , by(goma)
	}
	drop goma	
	
	
	
*** Figure 4: Self-reported behavioral change due to Covid-19 vs EVD in the full sample
	
	local var "a b c d e f g h"
	foreach v of local var {
	gen `v'=0
	}
	
	graph hbar (mean) a attit_coro1 attit_ebo1 b attit_coro2 attit_ebo2 c attit_coro3 attit_ebo3 d attit_coro4 attit_ebo4 e attit_coro5 attit_ebo5 f attit_coro6 attit_ebo6 g attit_coro7 attit_ebo7 h attit_coro8 attit_ebo8, legend(off) blabel(bar,format(%9.2f)) yscale(range(0 1)) ytitle("proportion of respondents")   ///
	ascategory yvar(relabel(1"avoid visiting family" 2" " 3" " 4"avoid visiting neighbors" 5" " 6" " 7"avoid taking public transport" 8" " 9" " 10"avoid going to markets" 11" " 12" " 13"avoid going to church" 14" " 15" " 16"staying more at home" 17" " 18" " 19"avoid shaking hands" 20" " 21" " 22"washing hands more frequently" 23" " 24" "))
	
	
	foreach num of numlist 1 4 7 10 13 16 19 22  {
	gr_edit plotregion1.bars[`num'].EditCustomStyle, j(-1) style(shadestyle(color(gs13)))
}
	foreach num of numlist 3 6 9 12 15 18 21 24  {
	gr_edit plotregion1.barlabels[`num'].Delete
}			
	drop a b c d e f g h
			

			
*** Figure 5: Self-reported behavioral change due to Covid-19 vs EVD by location
	
	graph hbar 	attit_coro1, over(location) saving(coro1,replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ysc(off) legend(off) title("avoid visiting family", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	graph hbar attit_coro2, over(location) saving(coro2, replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ysc(off) legend(off) title("avoid visiting neighbors", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	graph hbar attit_coro3, over(location) saving(coro3, replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ysc(off) legend(off) title("avoid taking public transport", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	graph hbar attit_coro4, over(location) saving(coro4, replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ylabel(0(0.2)1) legend(off) ytitle("proportion of respondents") title("avoid going to markets", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	graph hbar attit_coro5, over(location) saving(coro5, replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ysc(off) legend(off) title("avoid going to church", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	graph hbar attit_coro6, over(location) saving(coro6, replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ysc(off) legend(off) title("staying more at home", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	graph hbar attit_coro7, over(location) saving(coro7, replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ysc(off) legend(off) title("avoid shaking hands", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	graph hbar attit_coro8, over(location) saving(coro8, replace) ascategory blabel(bar,format(%9.2f)) /* 
	*/ yla(, ang(h)) ylabel(0(0.2)1) legend(off) ytitle("proportion of respondents") title("washing hands more frequently", size(medlarge) position(12)) yvar(relabel(1"{it:Goma}" 2"{it:Mutwanga}" 3"{it:Rutshuru}"))	 
	
	graph combine "coro1" "coro2" "coro3" "coro4", imargin(zero) xcommon ycommon col(1) xsize(3) ysize(4)	 
	graph combine "coro5" "coro6" "coro7" "coro8", imargin(zero) xcommon ycommon col(1) xsize(3) ysize(4)		 
		 
		 
		 
*** Figure 6: Self-reported likelihood of contracting Covid-19
		
	graph hbar corona_likely corona_unlikely corona_uncertain, legend(off) over (location) blabel(bar,format(%9.2f))  ///
	ascategory ylabel(0(0.2)1) yvar(relabel(1"{it:likely or very likely}" 2"{it:unlikely or very unlikely}" 3"{it:uncertain}")) ytitle("proportion of respondents") 
	
			
		
		
***************************************************************************************************
*** APPENDIX
***************************************************************************************************

*** Table A.1 construction quality of houses in the sample
	tab constr_qual if location==2 & hh==1
	tab constr_qual if location==2 & hh==2
	tab constr_qual if location==1 & hh==1
	tab constr_qual if location==1 & hh==2
	
	
*** Table A.2 Descriptive statistics for the household heads and business owners
	sum chef_age chef_male if hh==1 
	tab chef_educ if hh==1 
	
	sum age_patron male_patron if hh==2 
	tab education_patron if hh==2 

	
*** Table A.3 Self-reported impact of Covid-19 vs EVD in various sub-samples
	
	* Panels A-B: households & PMEs
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if hh==1
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if hh==2

	local var "revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola"
	foreach v of local var{
	ttest `v' , by(hh)
	}
	
	* Panels C-D: connected & not connected to Virunga's electricity grid
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if client_virunga==1
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if client_virunga==0
	
	local var "revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola"
	foreach v of local var{
	ttest `v' , by(client_virunga)
	}
	
	* Panels E-F: households with lowest & highest construction quality housing
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if constr_qual==1 & hh==1
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if constr_qual==4 & hh==1

	gen poor=1 if constr_qual==1 & hh==1 & sample==1
	replace poor=0 if constr_qual==4 & hh==1 & sample==1
	local var "revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola"
	foreach v of local var{
	ttest `v' , by(poor)
	}	
	
	* Panels G-H: households with lowest & highest education
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if chef_educ==1 
	sum revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola if chef_educ==5 
	
	gen noeduc=1 if chef_educ==1 & hh==1 
	replace noeduc=0 if chef_educ==5 & hh==1 
	local var "revenu_corona revenu_ebola food_corona food_ebola crime_corona crime_ebola"
	foreach v of local var{
	ttest `v' , by(noeduc)
	}			
		

















